package Demo01;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        Set<Integer> set = new TreeSet<>();
        set.add(1);
        set.add(5);
        set.add(3);
        set.add(6);
//        System.out.println(set);
        Iterator<Integer> it = set.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }
    public static void main02(String[] args) {
        Map<Integer,Double> map = new TreeMap<>();
        map.put(1,1.00);
        map.put(0,0.00);
        map.put(2,2.00);
        Set<Map.Entry<Integer, Double>> set = map.entrySet();
        for (Map.Entry<Integer, Double> x: set) {
            System.out.println(x.getKey()+" "+x.getValue());
        }
//        System.out.println(map);
    }
    public static void main01(String[] args) {
          Map<String,String> map = new TreeMap<>();
          map.put("二狗","大哥");
          map.put("二蛋","二哥");
          map.put("狗蛋","三哥");

        System.out.println(map.get("狗蛋"));
        System.out.println(map.getOrDefault("狗蛋","不存在此人"));
        System.out.println(map.getOrDefault("李四", "不存在此人"));
        map.remove("二狗");
        Set<String> set = map.keySet();
        System.out.println(set);

        Collection<String> collection = map.values();
        System.out.println(collection);

        Set<Map.Entry<String,String>> entrySet = map.entrySet();

        System.out.println(entrySet);



    }
}
